#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    pushCount = 0;
    ui->setupUi(this);
    button = new QPushButton(this);
    button->setText("Don`t fucking touch me!!!!!!");
    button->move(300,250);
    connect(button,&QPushButton::clicked,this,[&]()
    {
        button->move(0,0);
    });
//    connect(button,&QPushButton::clicked,this,&Widget::handleClick);
}
Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
    std::function<void(Widget*)>f1 = &Widget::signalFuc1;
    std::function<void(Widget*)>f2 = &Widget::signalFuc2;
    std::function<void(Widget*)>f3 = &Widget::signalFuc3;
    std::function<void(Widget*)>f4 = &Widget::signalFuc4;
    std::function<void(Widget*)>f5 = &Widget::signalFuc5;
    std::map<size_t,std::function<void(Widget*)>>hash;
    hash[0] = f1;
    hash[1] = f2;
    hash[2] = f3;
    hash[3] = f4;
    hash[4] = f5;
    hash[pushCount](this);
    Widget::pushCount++;
}

void Widget::signalFuc1()
{
    button->setText("FUCK YOU!!!!!!");
}
void Widget::signalFuc2()
{
    button->setText("FUCK YOU!!!");
}
void Widget::signalFuc3()
{
    button->setText("FUCK YOU!");
}
void Widget::signalFuc4()
{
    button->setText("FUCK YOU ALL!!");
}
void Widget::signalFuc5()
{
    Widget::setWindowTitle("fuck you!!!!!!");
    disconnect(button,&QPushButton::clicked,this,&Widget::handleClick);
    connect(button,&QPushButton::clicked,this,[this](){
        qDebug("fuck");
        qDebug()<<"fuck you";
        this->move(0,0);
    });
}
